package cn.itsource.pethome.util;

import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;

import javax.mail.internet.MimeMessage;
import java.io.File;

public class EailUtil {
    private static JavaMailSender javaMailSender ;
    public static void send2(String title,String eamil) throws Exception{
        //创建复杂邮件对象
        MimeMessage mimeMessage = javaMailSender.createMimeMessage();
        //发送复杂邮件的工具类
        MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true,"utf-8");
        helper.setFrom("mj宠物之家@qq.com");
        helper.setSubject(title);
        //第二个参数 true 代表是否是一个html内容
        helper.setText("<h1>审核通过，请点击激活</h1>"+
                "<a href=\"\">点击请激活</a>",true);
        //添加附件
        //helper.addAttachment("文件名.jpg",new File("C:\\aa.jpg"));
        //helper.addAttachment("压缩文件", new File("C:\\resources.zip"));
        //收件人
        helper.setTo(eamil);
        //发送邮件
        javaMailSender.send(mimeMessage);
    }
}
